package com.qfedu.fmmall.controller;

import com.qfedu.fmmall.common.status.ResStatus;
import com.qfedu.fmmall.common.vo.ResultVO;
import com.qfedu.fmmall.service.CategoryService;
import com.qfedu.fmmall.service.IndexImgService;
import com.qfedu.fmmall.service.ProductService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author : yanBin
 * @date :2021/12/14 14:26
 */
@RestController
@RequestMapping("/index")
@CrossOrigin
@Api(value = "提供首页数据显示所需管理", tags = "首页管理")
public class IndexImgController {
    @Autowired
    private IndexImgService indexImgService;
    @Autowired
    private CategoryService categoryService;
    @Autowired
    private ProductService productService;

    @GetMapping("/indeximg")
    @ApiOperation("首页轮播图接口")
    public ResultVO listIndexImg() {
        return indexImgService.listIndexImg();
    }


    @GetMapping("/category-list")
    @ApiOperation("首页类别列表接口")
    public ResultVO selectAllCategory() {
        return categoryService.selectAllCategory();
    }


    @GetMapping("/list-recommends")
    @ApiOperation("新品推荐接口")
    public ResultVO listRecommendProducts() {
        return new ResultVO(ResStatus.OK.ordinal(), "获取推荐算法成功", productService.listRecommendProducts());

    }
    @GetMapping("/category-recommends")
    @ApiOperation("分类推荐接口")
    public ResultVO listFirstLevelCategories(){
       return categoryService.listFirstLevelCategories();
    }
}
